package com.example.spring_boot_service.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result {
    private static final String  CODE_SUCCESS = "200";
    private static final String  AUTH_CODE_ERROR = "401";
    private static final String  CODE_SYS_ERROR = "500";
    private String code;
    private String message;
    private Object data;

    public static Result success(){
        return new Result(CODE_SUCCESS,"请求成功!",null);
    }
    public static Result success(Object data){
        return new Result(CODE_SUCCESS,"请求成功!",data);
    }
    public static void error(String message){
        new Result(CODE_SYS_ERROR, message, null);
    }
    public static Result error(String message,String code){
        return new Result(code,message,null);
    }
    public static Result error(){
        return new Result(AUTH_CODE_ERROR,"系统错误!",null);
    }
}
